<?php
/**
	Sponsor Manager (domains.php file)
    Copyright (C) <Fri Apr 11 22:06:56 CEST 2008>  Marcos Ramírez <marcosramirez@gmail.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    
    Purpose:
    Last Modified:
**/

global $sm;
global $html;
global $domains;
global $Cfg;

if ($_POST['action']=='checkDomain') {
	echo $domains->checkDomain($_POST['domain2check']);
	die();
}

//print_r($_POST);
if ($_POST['domain'])
	$domains->addDomain($_POST['domain']);

if ($_POST['domainList'])
	$domains->addDomainList($_POST['domainList']);
	
if ($_POST['ip'])
	$domains->addIp($_POST['ip']);

if ($_POST['ipList'])
	$domains->addIPList($_POST['ipList']);

	

$html->addJSFile('domains.js');
$html->addCSSFile('domains.css');
$html->header();



?>

<p><a href="#" id="clickAddDomain">Add Domain</a> - <a href="#" id="clickAddIp">Add IP</a>
</p>
<div id="addDomain">
<form method="post" action="">

<p>Enter single domain:</p>
<p><input type="text" name="domain" size="15" /></p>
<p>Or enter domain list (one per line)</p>
<p><textarea name="domainList" cols="50" rows="20"></textarea></p>
<input type="submit" value="<?=_('Send');?>" />
</form>
</div>


<div id="addIp">
<form method="post" action="">
<p>Enter single IP:</p>
<p><input type="text" name="ip" size="15" /></p>
<p>Or enter IP list (one per line)</p>
<p><textarea name="ipList" cols="50" rows="20"></textarea></p>
<input type="submit" value="<?=_('Send');?>" />
</form>
</div>
<?
$List=$domains->getDomainList();

echo '<table>
		<tr>
		<td>'._('Domain').'</td>
		<td>'._('Actual IP').'</td>
		<td>'._('Active').'</td>
		<td>'._('Sell in Sedo').'</td>
		</tr>';
//print_r($List);
foreach ($List as $numero) {
	echo '<tr>';
	foreach ($numero as $key => $value) {
		$cont++;
		//echo "$value ";
		echo '<td><a href="http://'.$value.'">'.$value.'</a></td>';
		echo '<td id="result'.$cont.'">
				<img src="/admin/templates/default/css/img/miniloading.gif" alt="Checking" />
				<script type="text/JavaScript">
				checkDomain("'.$value.'", "'.$cont.'");
				</script></td>';
		echo '<td>'.$domains->isActive($value).'</td>';
		echo '<td>'.$domains->isInSedo($value).'</td>';

	}
	echo '</tr>';
}
echo '</table>';



$html->footer();
?>